from config import config
from pypinyin import lazy_pinyin
class MyUrl:
    # 获取首页连接
    @staticmethod
    def getHost():
        return config["host"]

    # 获取文章的连接
    @staticmethod
    def getArt(art):
        if art == None:
            return MyUrl.getHost()
        if art.url == None:
            return MyUrl.getHost() + "/art/" + str(art.id)
        if len(art.url) == 0:
            return MyUrl.getHost() + "/art/" + str(art.id)
        return MyUrl.getHost() + "/a/" + art.url

    # 文字转pinyin
    @staticmethod
    def getPinYin(strs):
        return "_".join(lazy_pinyin(strs)).replace(' ','_')
